package com.mijie.homi.dao.user;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.mijie.core.IBatisDao;
import com.mijie.homi.common.domain.user.UserExtInfo;
import com.mijie.homi.common.util.HomiUtil;
import com.mijie.homi.domain.user.MoodUser;
import com.mijie.util.DateUtil;

@Repository
public class MoodUserDao extends IBatisDao {
	private Logger logger = Logger.getLogger(MoodUserDao.class);
	
	public List<MoodUser> listWithSameMood(Date pointInTime,UserExtInfo info,int offset,int limit,Integer gender,String order){
		HashMap<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("pointInTime", DateUtil.date2str(pointInTime, true));
		parameter.put("userId", info.getId());
		parameter.put("mood", HomiUtil.getMoodClan(info.getMood()));
		parameter.put("longitude", info.getLongitude());
		parameter.put("latitude", info.getLatitude());
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		parameter.put("order", order);
		if(gender!=null) parameter.put("gender", gender);
		return  this.selectList("listWithSameMood", parameter);
	}
	
	public List<MoodUser> listWithMatchMood(UserExtInfo info,int[] mood,int offset,int limit,Integer gender){
		HashMap<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("userId", info.getId());
		parameter.put("array", mood);
		parameter.put("longitude", info.getLongitude());
		parameter.put("latitude", info.getLatitude());
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		if(gender!=null) parameter.put("gender", gender);
		return this.selectList("listWithMatchMood", parameter);
	}
	
	public Integer countMoodUserAmount(int mood){
		return this.selectInteger("countMoodUserAmount", mood);
	}
	
}
